# -*- coding:utf-8 -*-
class Solution:
    def IsContinuous(self, numbers):
        # write code here
        if not numbers: return False
        numbers.sort()
        zeroNum = numbers.count(0)
        for i, v in enumerate(numbers[:-1]):
            if v != 0:
                if numbers[i+1]==v: return False
                zeroNum = zeroNum - (numbers[i + 1] - v) + 1
                if zeroNum < 0:
                    return False
        return True

'''
最大值和最小值小于4就ok
'''
# -*- coding:utf-8 -*-
class Solution2:
    def IsContinuous(self, numbers):
        # write code here
        if not numbers: return False
        numbers.sort()
        jokers = numbers.count(0)
        for i in range(jokers):
            numbers.pop(0)
        for j in range(1,len(numbers)):
            if numbers[j] == numbers[j-1]:
                return False
        if numbers[-1] - numbers[0]<= 4:
            return True
        return False
# -*- coding:utf-8 -*-
class Solution:
    def IsContinuous(self, numbers):
        # write code here
        if not numbers: return False
        numbers.sort()
        jokers = numbers.count(0)
        for i in range(jokers):
            numbers.pop(0)
        if len(numbers) == len(set(numbers)) and numbers[-1] - numbers[0]<= 4:
            return True
        return False
so = Solution2()
print(so.IsContinuous([0,3,1,6,4]))

'''
# 判断重复可以用
len(numbers)==len(set(numbers))
# 不排序可以直接求出来大小的差距
max(numbers) - min(numbers) <= 4
'''
# -*- coding:utf-8 -*-
class Solution:
    def IsContinuous(self, numbers):
        # write code here
        if len(numbers):
            while min(numbers)==0:
                numbers.remove(0)
            if max(numbers) - min(numbers)<=4 and len(numbers)==len(set(numbers)):
                return True
        return False
